//
//  Utils.h
//  Locbest
//
//  Created by ximenwuyou on 15-12-14.
//  Copyright (c) 2015年 ximenwuyou. All rights reserved.
//

#import <MBProgressHUD/MBProgressHUD.h>
//#import "LoginViewController.h"
#import <UIKit/UIKit.h>
#import <CoreImage/CoreImage.h>
//#import "CustomNoDataView.h"

@interface Utils : NSObject
NS_ASSUME_NONNULL_BEGIN
// 从十六进制字符创建UIColor
+ (UIColor *)colorWithHexString:(NSString *)hex;

//// 判断是否自动登录
//+ (void)isLogin:(UIViewController*)Self whichTabbarController:(WhichTabbar)which;

+ (void)isShowLoginFromVc:(UIViewController *)currentVc completion:(void (^ __nullable)(BOOL success))successOrFailBlock;

// 检测网络
+ (BOOL)isNetworkAvailableShowToast:(BOOL)isShow;

//获取当前时间转换为字符串格式
+ (NSString *)getNowDateTimeWithFormat:(NSString *)format;

+ (NSDate *)getNowDateTimeDate:(NSString *)string;
+ (float)getSecondsBetweenTwoDates:(NSDate *)nowDate andOld:(NSDate *)oldDate;


// 应用版本号
+ (NSString *)getAppVersion;

//返回沙盒路径
+ (NSString *)getDocumentDir;

//获取文件完整路径
+ (NSString *)getFilePath:(NSString *)fileName fromDir:(NSString *)dir;

//获取MD5加密后字符串
+ (NSString *)md5FromString:(NSString *)str;
+ (NSString *)md5:(NSString *)str;
//获取时间戳
+ (NSString *)getTimeSp;
//根据指定格式将NSDate转换为NSString
+ (NSString *)stringFromDate:(NSDate *)date formatter:(NSString *)formatter;
//根据指定格式将NSString转换为NSDate
+ (NSDate *)dateFromString:(NSString *)dateString formatter:(NSString *)formatter;
//秒转时间格式
+ (NSString *)timeFormatted:(int)totalSeconds;
//获取当前年份
+ (NSInteger)getCurrentYear;
//转换秒为时间格式
+ (NSString *)convertSecondToTime:(int)totalSeconds;

//验证手机号码合法性（正则）
+ (BOOL)phoneNumberCheck:(NSString *)phoneNumber;

#pragma mark - Toast
/**
 *  提示信息
 *
 *  @param viewCtrl viewCtrl description
 *  @param msage    msage 信息
 */
+ (void)showToast:(NSString *)msage withCtrl:(UIViewController *)viewCtrl;

/**
 *  提示信息
 *
 *  @param msage    msage 信息
 */
+ (void)showToastMessage:(NSString *)msage;
/**
 *  显示loading条
 *
 *  @param title title
 *  @param viewCtrl viewCtrl description
 *
 *  @return MBProgressHUD
 */
+ (MBProgressHUD *)showMBHUD:(NSString *)title withCtrl:(UIViewController *)viewCtrl;

/**
 *  关闭loading条
 *
 *  @param mbHud MBProgressHUD
 */
+ (void)dismissMBHUD:(MBProgressHUD *)mbHud;

//获取文件大小
+ (long)getFileSizeInPath:(NSString *)localPath;

//判断String不能全是相同的数字或者字母（如：000000、111111、aaaaaa)
+ (BOOL)isStringAllTheSame:(NSString*)str;

//判断String不能是连续递增或递减的数字（如：123456、12345678、987654、876543）
+ (BOOL)isIncreaseOrDecreaseInt:(NSString *)str;

//判断字符串长度是否过长（默认衡量参考值为屏幕with*0.55）
+ (BOOL)isStringTooLong:(NSString*)str;

//获取设备型号
+ (NSString *)getCurrentDeviceModel;

+ (NSString *)convert10TimespToString:(NSString *)timesp;
//银行卡验证
+ (BOOL)checkBankCardNo:(NSString*)cardNo;
//身份证验证
+(BOOL)checkIdentityCardNo:(NSString*)cardNo;
//是否是中文
+ (BOOL)isValidChinese:(NSString *)string;
//是否是数字
+ (BOOL)isValidNumber:(NSString *)string;
//判断是否是空格
+ (BOOL)isEmpty:(NSString *)string;

//生成二维码
+ (UIImage * _Nullable)createCodeGenerator:(NSString * _Nullable)urlString;
//获取高清图
+ (UIImage * _Nullable)createNonInterpolatedUIImageFormCIImage:(CIImage * _Nonnull)ciImage size:(CGFloat)widthAndHeight;
//修改图片颜色
+ (UIImage * _Nullable)imageBlackToTransparent:(UIImage *_Nonnull)image withRed:(CGFloat)red andGreen:(CGFloat)green andBlue:(CGFloat)blue;
//生成一个高清带颜色的二维码一
+ (UIImage * _Nullable)generatesHighDefinitionColorCode:(NSString *_Nonnull)urlString andSize:(CGFloat)widthAndHeight withRed:(CGFloat)red andGreen:(CGFloat)green andBlue:(CGFloat)blue;
//生成一个高清带颜色的二维码二
+ (UIImage * _Nullable)generatesHighDefinitionColorCode:(NSString *_Nullable)urlString andSize:(CGFloat)widthAndHeight withRGB:(NSDictionary *_Nullable)rgbColor;
//获取当前控制器
+ (UIViewController * _Nullable)CurrentViewController;

//手机号码中间4位取*
+ (NSString * _Nullable)returnSafeTelPhoneTextStringWithStandTelPhoneTextString:(NSString * _Nullable)standPhone;

+ (BOOL) validateEmail:(NSString *)email;

+ (NSDictionary *)readLocalDataWithFileName:(NSString *)fileName fileType:(NSString *)fileType;

NS_ASSUME_NONNULL_END
@end
